﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Trackr.DataAccess
{
	public class FakeTrackrDataStore : ITrackrDataStore
	{
		public IEnumerable<Trackr.Model.TimeItem> GetAll()
		{
			return GetFakeTimeItems(100);
		}
		public Trackr.Model.TimeItem Get(int Id)
		{
			return GetFakeTimeItem();
		}

		public Trackr.Model.TimeItem Get(Trackr.Model.TimeItem Id)
		{
			return GetFakeTimeItem();
		}

		public IEnumerable<Trackr.Model.TimeItem> GetAll(DateTime fromDate, DateTime toDate)
		{
			return GetFakeTimeItems(11);
		}

		public bool Delete(Trackr.Model.TimeItem timeItem)
		{
			return true;
		}

		public bool Save(Trackr.Model.TimeItem timeItem)
		{
			return true;
		}

		private IEnumerable<Trackr.Model.TimeItem> GetFakeTimeItems(int count)
		{
			for (int i = 0; i < count; i++)
			{
				yield return GetFakeTimeItem();
			}
		}
		private Trackr.Model.TimeItem GetFakeTimeItem()
		{
			return new Trackr.Model.TimeItem
			{
				Id = FakeGenerator.GetRandomNumber(),
				Task = FakeGenerator.GetRandomText(2),
				StartTime = FakeGenerator.GetRandomDate(),
				Duration = TimeSpan.FromMinutes(FakeGenerator.GetRandomNumber(1, 70)),
				ProjectId = FakeGenerator.GetRandomText(1)
			};
		}

	}
}
